#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a, const void* b)
{
    return (*(int*)a - *(int*)b);
}
int* targetIndices(int* nums, int numsSize, int target, int* returnSize) {
    qsort(nums, numsSize, sizeof(int), cmp);
    int k = 0;
    int* a = (int*)malloc(sizeof(int) * numsSize);
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] == target)
        {
            a[k++] = i;
        }

    }
    *returnSize = k;
    return a;
}

int main()
{
    int e[5] = { 1,2,5,2,3 };
    int* returnSize = 0;
    int* ret = targetIndices(e, 5, 2,returnSize);
    for (int i = 0; i < *returnSize; i++)
    {
        printf("%d ", ret[i]);
    }
    return 0;
}